#############################
## BLIS/Swayable: Figure 3 ##
#############################

# File Description: 
# Uses data/packages from O_Data.R
# Replicates Figure 3 from Fabric of Repair report (2025)
# Date Last Updated: 2 May 2025

#############################

# Creating a summary dataframe of baseline Reparations support by age groups
baseline_age_reparations <- 
  df %>% 
  group_by(race, age_groups) %>% 
  count(rep_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = rep_baseline_categorical) %>% 
  add_column(Movement = "Reparations")

# Creating a summary dataframe of baseline Land Back support by age
baseline_age_landback <- 
  df %>% 
  group_by(race, age_groups) %>% 
  count(landback_baseline_categorical) %>% 
  mutate(Percentage = n/sum(n) * 100) %>% 
  rename(baseline_support = landback_baseline_categorical) %>% 
  add_column(Movement = "Land Back")

# Combining both Reparations and Land Back dataframes
baseline_age <- bind_rows(baseline_age_reparations, baseline_age_landback)

# Plotting Figure 3
baseline_age %>% 
  ggplot(aes(x = age_groups, y = Percentage, fill = baseline_support)) +
  geom_bar(stat = "identity") +
  labs(title = "Baseline Support by Age",
       x = "Age",
       y = "Percentage",
       fill = "Support") +
  scale_y_continuous(labels = scales::percent_format(scale = 1)) +
  facet_grid(vars(Movement), vars(race)) + 
  theme(axis.text.x = element_text(angle = 45)) +
  scale_fill_manual(values = c('#F6A40E', '#F35018', '#5AAE7D')) + 
  theme_bw()
